import { YhBaseEntity, YhEntity } from "@/common/baseentity";
import { Column, Entity, JoinColumn, ManyToOne, OneToMany, PrimaryColumn } from "typeorm";
import { FeeInOutType, BooleanType } from '@/common/type/enum';
import { Cntr } from "@/container/entities/container.entity";
import { decimalTransformer } from "@/common/transform/DecimalTransformer";
import { Contract } from "@/transport/transport.entity";

@Entity({
    name: 'c_fee_ele'
})
export class FeeEle extends YhEntity {
    @PrimaryColumn({
        type: 'varchar',
        name: 'fee_ele',
        comment: '元素代码'
    })
    fee_ele: string;

    @Column({
        type: 'varchar',
        name: 'e_fld_nam',
        comment: '元素英文名称'
    })
    e_fld_nam: string;

    @Column({
        type: 'varchar',
        name: 'c_fld_nam',
        comment: '元素中文名称'
    })
    c_fld_nam: string;

    @Column({
        type: 'varchar',
        name: 'from_table',
        comment: '更新元素属性列表sql语句'
    })
    from_table: string;

    @OneToMany(() => FeeModEle, (feemodele) => feemodele.feeele)
    feemodeles: FeeModEle[];

    @OneToMany(() => FeeEleLov, (feeelelov) => feeelelov.feeele)
    feeelelovs: FeeEleLov[];
}

@Entity({
    name: 'c_fee_ele_lov'
})
export class FeeEleLov extends YhEntity {
    @PrimaryColumn({
        type: 'varchar',
        name: 'fee_ele',
        comment: '元素代码'
    })
    fee_ele: string;

    @PrimaryColumn({
        type: 'varchar',
        name: 'fld_cod',
        comment: '元素属性值'
    })
    fld_cod: string;

    @Column({
        type: 'varchar',
        name: 'e_fld_nam',
        comment: '值英文'
    })
    e_fld_nam: string;

    @Column({
        type: 'varchar',
        name: 'c_fld_nam',
        comment: '值中文'
    })
    c_fld_nam: string;

    @Column({
        type: 'int',
        name: 'lov_order',
        comment: '值排序'
    })
    lov_order: number;

    @ManyToOne(() => FeeEle, (feeele) => feeele.feeelelovs)
    @JoinColumn({
        name: 'fee_ele'
    })
    feeele: FeeEle;
}

@Entity({
    name: 'c_fee_mod'
})
export class FeeMod extends YhEntity {
    @PrimaryColumn({
        type: 'varchar',
        name: 'fee_mod_cod',
        comment: '模式代码'
    })
    fee_mod_cod: string;

    @Column({
        type: 'varchar',
        name: 'fee_mod_nam',
        comment: '模式名称'
    })
    fee_mod_nam: string;

    @OneToMany(() => FeeCodMod, (feecodmod) => feecodmod.feemod)
    feecodmods: FeeCodMod[];

    @OneToMany(() => FeeModEle, (feemodele) => feemodele.feemod)
    feemodeles: FeeModEle[];
}


@Entity({
    name: 'c_fee_mod_ele'
})
export class FeeModEle  extends YhEntity {
    @PrimaryColumn({
        type: 'varchar',
        name: 'fee_mod_cod',
        comment: '模式代码'
    })
    fee_mod_cod: string;

    @PrimaryColumn({
        type: 'varchar',
        name: 'fee_ele',
        comment: '元素'
    })
    fee_ele: string;

    @Column({
        type: 'int',
        name: 'fee_ele_seq',
        comment: '排序'
    })
    fee_ele_seq: number;

    @ManyToOne(() => FeeMod, (feemod) => feemod.feemodeles)
    @JoinColumn({
        name: 'fee_mod_cod'
    })
    feemod: FeeMod;

    @ManyToOne(() => FeeEle, (feeele) => feeele.feemodeles)
    @JoinColumn({
        name: 'fee_ele'
    })
    feeele: FeeEle;
}

@Entity({
    name: 'c_protocol'
})
export class Protocol extends YhEntity {
    @PrimaryColumn({
        type: 'varchar',
        name: 'protocol_cod',
        comment: '协议代码'
    })
    protocol_cod: string;

    @Column({
        type: 'varchar',
        name: 'protocol_nam',
        comment: '协议名称'
    })
    protocol_nam: string;
}

@Entity({
    name: 'c_protocol_rat'
})
export class ProtocolRat extends YhBaseEntity {
    @Column({
        type: 'varchar',
        name: 'protocol_cod',
        comment: '协议代码'
    })
    protocol_cod: string;

    @Column({
        type: 'varchar',
        name: 'fee_cod',
        comment: '费目'
    })
    fee_cod: string;

    @Column({
        type: 'varchar',
        name: 'fee_mod_cod',
        comment: '费用模式'
    })
    fee_mod_cod: string;

    @Column({
        type: 'varchar',
        name: 'fee_ele1',
        comment: '元素1'
    })
    fee_ele1: string;

    @Column({
        type: 'varchar',
        name: 'fee_ele2',
        comment: '元素2'
    })
    fee_ele2: string;

    @Column({
        type: 'varchar',
        name: 'fee_ele3',
        comment: '元素3'
    })
    fee_ele3: string;

    @Column({
        type: 'varchar',
        name: 'fee_ele4',
        comment: '元素4'
    })
    fee_ele4: string;

    @Column({
        type: 'varchar',
        name: 'fee_ele5',
        comment: '元素5'
    })
    fee_ele5: string;

    @Column({
        type: 'varchar',
        name: 'fee_ele6',
        comment: '元素6'
    })
    fee_ele6: string;

    @Column({
        type: 'varchar',
        name: 'fee_ele7',
        comment: '元素7'
    })
    fee_ele7: string;

    @Column({
        type: 'varchar',
        name: 'fee_ele8',
        comment: '元素8'
    })
    fee_ele8: string;

    @Column({
        type: 'varchar',
        name: 'fee_ele9',
        comment: '元素9'
    })
    fee_ele9: string;

    @Column({
        type: 'varchar',
        name: 'fee_ele10',
        comment: '元素10'
    })
    fee_ele10: string;

    @Column({
        type: 'decimal',
        name: 'fee_rat',
        comment: '费率',
        transformer: decimalTransformer
    })
    fee_rat: number;
}


@Entity({
    name: 'c_fee_cod'
})
export class FeeCod extends YhEntity {
    @PrimaryColumn({
        type: 'varchar',
        name: 'fee_cod',
        comment: '费目代码'
    })
    fee_cod: string;

    @Column({
        type: 'varchar',
        name: 'fee_nam',
        comment: '费目名称'
    })
    fee_nam: string;

    @OneToMany(() => FeeCodMod, (feecodmod) => feecodmod.feecod)
    feecodmods: FeeCodMod[];
    @OneToMany(() => FeeTypCod, (feetypcod) => feetypcod.feecod)
    feetypcods: FeeTypCod[]
   
}
@Entity({
    name: 'c_fee_typ'
})
export class FeeTyp extends YhEntity {
    @PrimaryColumn({
        type: 'varchar',
        name: 'fee_typ_cod',
        comment: 'fee_typ代码'
    })
    fee_typ_cod: string;

    @Column({
        type: 'varchar',
        name: 'fee_typ_nam',
        comment: 'fee_typ名称'
    })
    fee_typ_nam: string;

    @OneToMany(() => FeeTypCod, (feetypcod) => feetypcod.feetyp)
    feetypcods: FeeTypCod[]

    @OneToMany(() => FeeDet, (feedet) => feedet.feetyp)
    feedets: FeeDet[];
}

@Entity({
    name: 'c_fee_typ_cod'
})
export class FeeTypCod extends YhEntity {
    @PrimaryColumn({
        type: 'varchar',
        name: 'fee_typ_cod',
        comment: '费用类型'
    })
    fee_typ_cod: string;

    @PrimaryColumn({
        type: 'varchar',
        name: 'fee_cod',
        comment: '费目'
    })
    fee_cod: string;

    @ManyToOne(() => FeeTyp, (feetyp) => feetyp.feetypcods)
    @JoinColumn({
        name: 'fee_typ_cod'
    })
    feetyp: FeeTyp;

    @ManyToOne(() => FeeCod, (feecod) => feecod.feetypcods)
    @JoinColumn({
        name: 'fee_cod'
    })
    feecod: FeeCod;
    
}

@Entity({
    name: 'c_fee_cod_mod'
})
export class FeeCodMod extends YhEntity {
    @PrimaryColumn({
        type: 'varchar',
        name: 'fee_cod',
        comment: '费目'
    })
    fee_cod: string;

    @PrimaryColumn({
        type: 'varchar',
        name: 'fee_mod',
        comment: '模式'
    })
    fee_mod: string;

    @Column({
        type: 'int',
        name: 'mod_seq',
        comment: '排序'
    })
    mod_seq: number;

    @ManyToOne(() => FeeCod, (feecod) => feecod.feecodmods)
    @JoinColumn({
        name: 'fee_cod',
    })
    feecod: FeeCod;

    @ManyToOne(() => FeeMod, (feemod) => feemod.feecodmods)
    @JoinColumn({
        name: 'fee_mod',
    })
    feemod: FeeMod;

}
@Entity({
    name: 'c_category'
})
export class Category extends YhBaseEntity {
    @Column({
        type: 'varchar',
        name: 'cate_item_nam',
        comment: '资金账号名称'
    })
    cate_item_nam: string;

    @Column({
        type: 'varchar',
        name: 'currency_cod',
        comment: '账号货币'
    })
    currency_cod: string;

    @Column({
        type: 'varchar',
        name: 'account',
        comment: '资金账号'
    })
    account: string;

    @Column({
        type: 'varchar',
        name: 'bank',
        comment: '银行名称'
    })
    bank: string;
}
@Entity({
    name: 'v_category_surplus'
})
export class VCategorySurplus {
    @PrimaryColumn({
        type: 'int',
        name: 'pay_typ',
        comment: '资金账号'
    })
    pay_typ: number;

    @PrimaryColumn({
        type: 'varchar',
        name: 'currency_cod',
        comment: '账号货币'
    })
    currency_cod: string;

    @Column({
        type: 'decimal',
        name: 'surplus',
        comment: '剩余金额',
        transformer: decimalTransformer
    })
    surplus: number;
}
@Entity({
    name: 'v_category_detail'
})
export class VCategoryDetail {
    @PrimaryColumn({
        type: 'int',
        name: 'id',
        comment: 'ID'
    })
    id: number;

    @PrimaryColumn({
        type: 'varchar',
        name: 'pay_kind',
        comment: '实付款/预付款'
    })
    pay_kind: string; 
    
    @Column({
        type: 'int',
        name: 'pay_typ',
        comment: '资金账号'
    })
    pay_typ: number;

    @Column({
        type: 'int',
        name: 'fee_unit_cod',
        comment: '客户'
    })
    fee_unit_cod: number;
    
    @Column({
        type: 'datetime',
        name: 'fee_tim',
        comment: '付款时间'
    })
    fee_tim: Date;

    @Column({
        type: 'varchar',
        name: 'fee_in_out',
        comment: '收付款'
    })
    fee_in_out: string;

    @Column({
        type: 'varchar',
        name: 'currency_cod',
        comment: '账号货币'
    })
    currency_cod: string;

    @Column({
        type: 'decimal',
        name: 'amount',
        comment: '余额',
        transformer: decimalTransformer
    })
    amount: number;

}

@Entity({
    name: 'c_rmb_rate'
})
export class Currency extends YhEntity {
    @PrimaryColumn({
        type: 'varchar',
        name: 'currency_cod',
        comment: '货币代码'
    })
    currency_cod: string;

    @Column({
        type: 'varchar',
        name: 'currency_nam',
        comment: '货币名称'
    })
    currency_nam: string;

    @Column({
        type: 'decimal',
        precision: 8,
        scale: 4,
        name: 'rate',
        comment: '汇率',
        transformer: decimalTransformer
    })
    rate: number;

    @OneToMany(() => FeeDet, (feedet) => feedet.currency)
    feedets: FeeDet[];
}
@Entity({
    name: 'c_exchange_rate'
})
export class ExchangeRate extends YhEntity {
    @PrimaryColumn({
        type: 'varchar',
        name: 'from_currency',
        comment: '源货币代码'
    })
    from_currency: string;
    @PrimaryColumn({
        type: 'varchar',
        name: 'to_currency',
        comment: '目标货币代码'
    })
    to_currency: string;
    @Column({
        type: 'decimal',
        precision: 10,
        scale: 4,
        name: 'rate',
        comment: '汇率',
        transformer: decimalTransformer
    })
    rate: number;
    
}
@Entity({
    name: 'pay'
})
export class Pay extends YhBaseEntity {
    @Column({
        type: 'int',
        name: 'fee_unit_cod',
        comment: '客户'
    })
    fee_unit_cod: number;
    @Column({
        type: 'int',
        name: 'fee_owner',
        comment: '成本中心'
    })
    fee_owner: number;
    @Column({
        type: 'varchar',
        name: 'fee_typ_cod',
        comment: '费用类型'
    })
    fee_typ_cod: string;
    @Column({
        type: 'varchar',
        name: 'fee_cod',
        comment: '费目'
    })
    fee_cod: string;

    @Column({
        type: 'decimal',
        name: 'amount',
        comment: '金额',
        transformer: decimalTransformer
    })
    amount: number;

    @Column({
        type: 'varchar',
        name: 'currency_cod',
        comment: '货币'
    })
    currency_cod: string;

    @Column({
        type: 'decimal',
        name: 'st_amount',
        comment: '人民币金额',
        transformer: decimalTransformer
    })
    st_amount: number;

    @Column({
        type: 'decimal',
        precision: 14,
        scale: 4,
        name: 'currency_rate',
        comment: '汇率',
        transformer: decimalTransformer
    })
    currency_rate: number;

    @Column({
        type: 'varchar',
        name: 'fee_nam',
        comment: '计费员'
    })
    fee_nam: string;
    
    @Column({
        type: 'datetime',
        name: 'fee_tim',
        comment: '付款时间'
    })
    fee_tim: Date

    @Column({
        type: 'int',
        name: 'pay_typ',
        comment: '资金账号'
    })
    pay_typ: number;

    @Column({
        type: 'enum',
        enum: FeeInOutType,
        name: 'fee_in_out',
        comment: '收付类型'
    })
    fee_in_out: string;
    /* @Column({
        type: 'int',
        name: 'plan_id',
        comment: '计划号'
    })
    plan_id: number; */
    
    @Column({
        type: 'enum',
        enum: BooleanType,
        name: 'audit_id',
        comment: '核销标识'
    })
    audit_id: string;

    @Column({
        type: 'enum',
        enum: BooleanType,
        name: 'audit_finish_id',
        comment: '核销完毕'
    })
    audit_finish_id: string;

    @Column({
        type: 'enum',
        enum: BooleanType,
        name: 'invoice_audit_id',
        comment: '发票核销标识'
    })
    invoice_audit_id: BooleanType

    @Column({
        type: 'enum',
        enum: BooleanType,
        name: 'invoice_audit_finish_id',
        comment: '发票核销完成标识'
    })
    invoice_audit_finish_id: BooleanType;

    @Column({
        type: 'varchar',
        name: 'pay_no',
        comment: '付款码'
    })
    pay_no: string;

    @Column({
        type: 'enum',
        enum: BooleanType,
        name: 'special_id',
        comment: '特殊费用'
    })
    special_id: string;

    @Column({
        type: 'enum',
        enum: BooleanType,
        name: 'need_audit',
        comment: '需要核销'
    })
    need_audit: string;

    @Column({
        type: 'int',
        name: 'cfs_cod',
        comment: '站点'
    })
    cfs_cod: number;

    @Column({
        type: 'varchar',
        name: 'fee_bill_no',
        comment: '账单号'
    })
    fee_bill_no: string;

    @Column({
        type: 'enum',
        enum: BooleanType,
        name: 'auto_audit',
        comment: '直接核销'
    })
    auto_audit: string;
}

@Entity({
    name: 'v_pay'
})
export class VPay extends Pay {
    @Column({
        type: 'decimal',
        name: 'unaudit_amount',
        comment: '未核销金额',
        transformer: decimalTransformer
    })
    unaudit_amount: number;

    @Column({
        type: 'decimal',
        name: 'unaudit_invoice_amount',
        comment: '未核销发票',
        transformer: decimalTransformer
    })
    unaudit_invoice_amount: number;
}

@Entity({
    name: 'pre_pay'
})
export class PrePay extends YhBaseEntity {
    @Column({
        type: 'int',
        name: 'fee_unit_cod',
        comment: '客户'
    })
    fee_unit_cod: number;
    @Column({
        type: 'int',
        name: 'fee_owner',
        comment: '成本中心'
    })
    fee_owner: number;
    @Column({
        type: 'varchar',
        name: 'fee_typ_cod',
        comment: '费用类型'
    })
    fee_typ_cod: string;
    @Column({
        type: 'varchar',
        name: 'fee_cod',
        comment: '费目'
    })
    fee_cod: string;
    @Column({
        type: 'decimal',
        name: 'amount',
        comment: '金额',
        transformer: decimalTransformer
    })
    amount: number;

    @Column({
        type: 'varchar',
        name: 'currency_cod',
        comment: '货币'
    })
    currency_cod: string;

    @Column({
        type: 'varchar',
        name: 'fee_nam',
        comment: '操作员'
    })
    fee_nam: string;

    @Column({
        type: 'datetime',
        name: 'fee_tim',
        comment: '付款时间'
    })
    fee_tim: Date

    @Column({
        type: 'int',
        name: 'pay_typ',
        comment: '资金账号'
    })
    pay_typ: number;

    @Column({
        type: 'enum',
        enum: FeeInOutType,
        name: 'fee_in_out',
        comment: '收付类型'
    })
    fee_in_out: string;
    @Column({
        type: 'varchar',
        name: 'pay_no',
        comment: '付款码'
    })
    pay_no: string;
}


@Entity({
    name: 'v_pre_audit_invoice_pay'
})
export class VPreAuditInvoicePay extends VPay {
    
}

@Entity({
    name: 'v_audit_pay'
})
export class VAuditPay extends Pay {
    @Column({
        type: 'decimal',
        name: 'unaudit_amount',
        comment: '未核销金额',
        transformer: decimalTransformer
    })
    unaudit_amount: number;
}
@Entity({
    name: 'fee_det'
})
export class FeeDet extends YhBaseEntity {
    @Column({
        type: 'varchar',
        name: 'total_no',
        comment: '组件编号'
    })
    total_no: string;

    @Column({
        type: 'varchar',
        name: 'fee_bill_no',
        comment: '账单编号'
    })
    fee_bill_no: string;

    @Column({
        type: 'varchar',
        name: 'bill_no',
        comment: '提单号'
    })
    bill_no: string;

    @Column({
        type: 'int',
        name: 'fix_list_id',
        comment: '修箱明细ID, fix_list.id'
    })
    fix_list_id: number;

    @Column({
        type: 'int',
        name: 'fee_unit_cod',
        comment: '客户'
    })
    fee_unit_cod: number;

    @Column({
        type: 'int',
        name: 'cntr_no',
        comment: '箱编号'
    })
    cntr_no: number;

    @Column({
        type: 'int',
        name: 'fee_owner',
        comment: '成本中心'
    })
    fee_owner: number;

    @Column({
        type: 'varchar',
        name: 'fee_typ_cod',
        comment: '费用类型'
    })
    fee_typ_cod: string;
    
    @Column({
        type: 'varchar',
        name: 'fee_cod',
        comment: '费目'
    })
    fee_cod: string;

    @Column({
        type: 'decimal',
        precision: 10,
        scale: 2,
        name: 'fee_value',
        comment: '单价',
        transformer: decimalTransformer
    })
    fee_value: number;

    @Column({
        type: 'decimal',
        precision: 10,
        scale: 2,
        name: 'st_value',
        comment: '人民币单价',
        transformer: decimalTransformer
    })
    st_value: number;

    @Column({
        type: 'decimal',
        precision: 10,
        scale: 2,
        name: 'fee_ton',
        comment: '数量',
        transformer: decimalTransformer
    })
    fee_ton: number;

    @Column({
        type: 'decimal',
        precision: 10,
        scale: 2,
        name: 'amount',
        comment: '金额',
        transformer: decimalTransformer
    })
    amount: number;

    @Column({
        type: 'decimal',
        precision: 10,
        scale: 2,
        name: 'st_amount',
        comment: '人民币金额',
        transformer: decimalTransformer
    })
    st_amount: number;

    @Column({
        type: 'varchar',
        name: 'currency_cod',
        comment: '货币'
    })
    currency_cod: string;

    @Column({
        type: 'varchar',
        name: 'pay_no',
        comment: '付款码'
    })
    pay_no: string;

    @Column({
        type: 'int',
        name: 'contract_id',
        comment: 'contract.id'
    })
    contract_id: number;

    /*
    @Column({
        type: 'int',
        name: 'in_truck_sn',
        comment: '进场计划号'
    })
    in_truck_sn: number; */
    @Column({
        type: 'int',
        name: 'lease_sn',
        comment: '计划号'
    })
    lease_sn: number;
    
    @Column({
        type: 'varchar',
        name: 'fee_nam',
        comment: '计费员'
    })
    fee_nam: string;

    @Column({
        type: 'datetime',
        name: 'fee_tim',
        comment: '计费时间',
    })
    fee_tim: Date;

    
    @Column({
        type: 'varchar',
        name: 'pay_way_id',
        comment: '付款类型'
    })
    pay_way_id: string;

    @Column({
        type: 'enum',
        enum: FeeInOutType,
        name: 'fee_in_out',
        comment: '收付类型'
    })
    fee_in_out: string;

    @Column({
        type: 'enum',
        enum: BooleanType,
        name: 'audit_id',
        comment: '核销标识'
    })
    audit_id: BooleanType;

    @Column({
        type: 'enum',
        enum: BooleanType,
        name: 'audit_finish_id',
        comment: '核销完毕标识'
    })
    audit_finish_id: BooleanType;

    @Column({
        type: 'enum',
        enum: BooleanType,
        name: 'invoice_audit_id',
        comment: '发票核销标识'
    })
    invoice_audit_id: BooleanType;

    @Column({
        type: 'enum',
        enum: BooleanType,
        name: 'invoice_audit_finish_id',
        comment: '发票核销完成标识'
    })
    invoice_audit_finish_id: BooleanType;

    @ManyToOne(() => Cntr, (cntr) => cntr.feedets)
    @JoinColumn({
        name: 'cntr_no'
    })
    cntr: Cntr;

    @ManyToOne(() => Currency, (currency) => currency.feedets)
    @JoinColumn({
        name: 'currency_cod'
    })
    currency: Currency;

    @ManyToOne(() => FeeTyp, (fee_typ) => fee_typ.feedets)
    @JoinColumn({
        name: 'fee_typ_cod'
    })
    feetyp: FeeTyp;

    @ManyToOne(() => Contract, (contract) => contract.feedets)
    @JoinColumn({
        name: 'contract_id'
    })
    contract: Contract;
}

@Entity({
    name: 'v_feedet'
})
export class VFeedet extends YhBaseEntity {
    /* @Column({
        type: 'varchar',
        name: 'total_no',
        comment: '组件编号'
    })
    total_no: string;
 */
    @Column({
        type: 'varchar',
        name: 'fee_bill_no',
        comment: '账单编号'
    })
    fee_bill_no: string;

    @Column({
        type: 'varchar',
        name: 'bill_no',
        comment: '提单号'
    })
    bill_no: string;

    @Column({
        type: 'int',
        name: 'fix_list_id',
        comment: '修箱明细ID, fix_list.id'
    })
    fix_list_id: number;

    @Column({
        type: 'int',
        name: 'fee_unit_cod',
        comment: '客户'
    })
    fee_unit_cod: number;

    @Column({
        type: 'int',
        name: 'cntr_no',
        comment: '箱编号'
    })
    cntr_no: number;

    @Column({
        type: 'int',
        name: 'fee_owner',
        comment: '成本中心'
    })
    fee_owner: number;

    @Column({
        type: 'varchar',
        name: 'fee_typ_cod',
        comment: '费用类型'
    })
    fee_typ_cod: string;
    
    @Column({
        type: 'varchar',
        name: 'fee_cod',
        comment: '费目'
    })
    fee_cod: string;

    @Column({
        type: 'decimal',
        precision: 10,
        scale: 2,
        name: 'fee_value',
        comment: '单价',
        transformer: decimalTransformer
    })
    fee_value: number;

    @Column({
        type: 'decimal',
        precision: 10,
        scale: 2,
        name: 'st_value',
        comment: '人民币单价',
        transformer: decimalTransformer
    })
    st_value: number;

    @Column({
        type: 'decimal',
        precision: 10,
        scale: 2,
        name: 'fee_ton',
        comment: '数量',
        transformer: decimalTransformer
    })
    fee_ton: number;

    @Column({
        type: 'decimal',
        precision: 10,
        scale: 2,
        name: 'amount',
        comment: '金额',
        transformer: decimalTransformer
    })
    amount: number;

    @Column({
        type: 'decimal',
        precision: 10,
        scale: 2,
        name: 'st_amount',
        comment: '人民币金额',
        transformer: decimalTransformer
    })
    st_amount: number;

    @Column({
        type: 'varchar',
        name: 'currency_cod',
        comment: '货币'
    })
    currency_cod: string;
    @Column({
        type: 'int',
        name: 'lease_sn',
        comment: '计划号'
    })
    lease_sn: number;

    @Column({
        type: 'varchar',
        name: 'pay_no',
        comment: '付款码'
    })
    pay_no: string;

    @Column({
        type: 'varchar',
        name: 'fee_nam',
        comment: '计费员'
    })
    fee_nam: string;

    @Column({
        type: 'datetime',
        name: 'fee_tim',
        comment: '计费时间'
    })
    fee_tim: Date;

    @Column({
        type: 'varchar',
        name: 'pay_way_id',
        comment: '付款类型'
    })
    pay_way_id: string;

    @Column({
        type: 'enum',
        enum: FeeInOutType,
        name: 'fee_in_out',
        comment: '收付类型'
    })
    fee_in_out: string;

    @Column({
        type: 'enum',
        enum: BooleanType,
        name: 'audit_id',
        comment: '核销标识'
    })
    audit_id: string;

    @Column({
        type: 'enum',
        enum: BooleanType,
        name: 'audit_finish_id',
        comment: '核销完毕标识'
    })
    audit_finish_id: string;

    @Column({
        type: 'enum',
        enum: BooleanType,
        name: 'invoice_audit_id',
        comment: '发票核销标识'
    })
    invoice_audit_id: BooleanType;

    @Column({
        type: 'enum',
        enum: BooleanType,
        name: 'invoice_audit_finish_id',
        comment: '发票核销'
    })


    @Column({
        type: 'varchar',
        name: 'cntr',
        comment: '箱号'
    })
    cntr: string;

    @Column({
        type: 'varchar',
        name: 'cntr_siz_cod',
        comment: '箱尺寸'
    })
    cntr_siz_cod: string;
    @Column({
        type: 'varchar',
        name: 'cntr_typ_cod',
        comment: '箱型'
    })
    cntr_typ_cod: string;
    @Column({
        type: 'int',
        name: 'in_truck_sn',
        comment: '进场计划号'
    })
    in_truck_sn: number;
    @Column({
        type: 'int',
        name: 'out_truck_sn',
        comment: '出场计划号'
    })
    out_truck_sn: number;
    @Column({
        type: 'int',
        name: 'cntr_owner',
        comment: '成本中心'
    })
    cntr_owner: number;


}

@Entity({
    name: 'v_yewu_feedet'
})
export class VYewuFeedet extends VFeedet {

}   

@Entity({
    name: 'v_pre_audit_invoice_feedet'
})
export class VPreAuditInvoiceFeedet extends VFeedet {

}

@Entity({
    name: 'v_audit_feedet'
})
export class VAuditFeedet extends VFeedet {
    @Column({
        type: 'decimal',
        name: 'unaudit_amount',
        comment: '未核销金额',
        transformer: decimalTransformer
    })
    unaudit_amount: number;
}

@Entity({
    name: 'v_feedet_audit_invoice'
})
export class VFeedetAuditInvoice extends FeeDet {
    @Column({
        type: 'decimal',
        name: 'unaudit_invoice_amount',
        comment: '未核销发票金额',
        transformer: decimalTransformer
    })
    unaudit_invoice_amount: number;
}


@Entity({
    name: 'fee_audit'
})
export class FeeAudit extends YhBaseEntity {
    @Column({
        type: 'int',
        name: 'pay_id',
        comment: 'pay.id'
    })
    pay_id: number;

    @Column({
        type: 'int',
        name: 'feedet_id',
        comment: 'feedet.id'
    })
    feedet_id: number;

    @Column({
        type: 'decimal',
        name: 'pay_amount',
        comment: '核销实收付金额',
        transformer: decimalTransformer
    })
    pay_amount: number;

    @Column({
        type: 'datetime',
        name: 'audit_tim',
        comment: '核销时间'
    })
    audit_tim: Date;

    @Column({
        type: 'varchar',
        name: 'audit_no',
        comment: '核销号'
    })
    audit_no: string;


    @Column({
        type: 'decimal',
        name: 'feedet_amount',
        comment: '应收付金额',
        transformer: decimalTransformer
    })
    feedet_amount: number;

    @Column({
        type: 'decimal',
        precision: 8,
        scale: 4,
        name: 'currency_rate',
        comment: '汇率',
        transformer: decimalTransformer
    })
    currency_rate: number;

    @Column({
        type: 'enum',
        enum: BooleanType,
        name: 'force_flag',
        comment: '强制核销标志'
    })
    force_flag: BooleanType;
}

@Entity({
    name: 'v_audit'
})
export class VAudit extends FeeAudit {
    @Column({
        type: 'varchar',
        name: 'pay_currency',
        comment: '实收付货币'
    })
    pay_currency: string;

    @Column({
        type: 'varchar',
        name: 'feedet_currency',
        comment: '应收付货币'
    })
    feedet_currency: string;
}

/* @Entity({
    name: 'fee_audit_plus'
})
export class FeeAuditPlus extends YhBaseEntity {
    @Column({
        type: 'decimal',
        name: 'pay_amount',
        comment: '核销实收付金额',
        transformer: decimalTransformer
    })
    pay_amount: number;

    @Column({
        type: 'decimal',
        name: 'feedet_amount',
        comment: '人民币金额',
        transformer: decimalTransformer
    })
    feedet_amount: number;

    @Column({
        type: 'int',
        name: 'pay_id',
        comment: 'pay.id'
    })
    pay_id: number;

    @Column({
        type: 'int',
        name: 'feedet_id',
        comment: 'fee_det.id'
    })
    feedet_id: number;

    @Column({
        type: 'varchar',
        name: 'audit_no',
        comment: '核销号'
    })
    audit_no: string;

    @Column({
        type: 'datetime',
        name: 'audit_tim',
        comment: '核销时间'
    })
    audit_tim: Date;
    
    @Column({
        type: 'decimal',
        precision: 8,
        scale: 4,
        name: 'currency_rate',
        comment: '汇率',
        transformer: decimalTransformer
    })
    currency_rate: number;
} */

@Entity({
    name: 'v_audit_group'
})
export class VAuditGroup {
    @PrimaryColumn({
        type: 'varchar',
        name: 'audit_no',
        comment: '核销号'
    })
    audit_no: string;
    @Column({
        type: 'datetime',
        name: 'audit_tim',
        comment: '核销时间'
    })
    audit_tim: Date;
    @Column({
        type: 'int',
        name: 'fee_unit_cod',
        comment: '客户'
    })
    fee_unit_cod: number;
}

@Entity({
    name: 'invoice'
})
export class Invoice extends YhBaseEntity {
    @Column({
        type: 'varchar',
        name: 'from_corp_nam',
        comment: '销售方'
    })
    from_corp_nam: string;
    @Column({
        type: 'varchar',
        name: 'to_corp_nam',
        comment: '购买方'
    })
    to_corp_nam: string;

    @Column({
        type: 'varchar',
        name: 'invoice_no',
        comment: '发票号'
    })
    invoice_no: string;

    @Column({
        type: 'varchar',
        name: 'invoice_cod',
        comment: '发票代码'
    })
    invoice_cod: string;

    /* @Column({
        type: 'varchar',
        name: 'fee_unit_nam',
        comment: '户头'
    })
    fee_unit_nam: string; */

    @Column({
        type: 'datetime',
        name: 'invoice_date',
        comment: '发票日期'
    })
    invoice_date: Date;

   /*  @Column({
        type: 'varchar',
        name: 'tax_no',
        comment: '税号'
    })
    tax_no: string; */

    @Column({
        type: 'decimal',
        name: 'cost_amount',
        comment: '非含税价',
        transformer: decimalTransformer
    })
    cost_amount: number;

    @Column({
        type: 'decimal',
        name: 'tax_rate',
        comment: '税率',
        transformer: decimalTransformer
    })
    tax_rate: number;

    @Column({
        type: 'decimal',
        name: 'tax_amount',
        comment: '税额',
        transformer: decimalTransformer
        //generatedType: 'STORED'
    })
    tax_amount: number;

    @Column({
        type: 'decimal',
        name: 'amount',
        comment: '金额',
        transformer: decimalTransformer
        // generatedType: 'STORED'
    })
    amount: number;

    @Column({
        type: 'varchar',
        name: 'currency_cod',
        comment: '货币'
    })
    currency_cod: string;

    @Column({
        type: 'enum',
        enum: BooleanType,
        name: 'pay_audit_id',
        comment: 'PAY核销标识'
    })
    pay_audit_id: BooleanType;

    @Column({
        type: 'enum',
        enum: BooleanType,
        name: 'pay_audit_finish_id',
        comment: 'pay核销完成标识'
    })
    pay_audit_finish_id: BooleanType;

    @Column({
        type: 'enum',
        enum: BooleanType,
        name: 'feedet_audit_id',
        comment: 'FEEDET核销标识'
    })    
    feedet_audit_id: BooleanType;

    @Column({
        type: 'enum',
        enum: BooleanType,
        name: 'feedet_audit_finish_id',
        comment: 'pay核销完成标识'
    })
    feedet_audit_finish_id: BooleanType;

    @OneToMany(() => InvoiceDetail, (detail) => detail.invoice)
    details: InvoiceDetail[];
}

@Entity({
    name: 'invoice_detail'
})
export class InvoiceDetail extends YhBaseEntity {
    @Column({
        type: 'int',
        name: 'invoice_id',
        comment: '发票ID'
    })
    invoice_id: number;

    @Column({
        type: 'varchar',
        name: 'cntr_typ',
        comment: '箱型'
    })
    cntr_typ: string;

    @Column({
        type: 'varchar',
        name: 'status',
        comment: '箱况'
    })
    status: string;

    @Column({
        type: 'varchar',
        name: 'description',
        comment: '描述'
    })
    description: string;

    @Column({
        type: 'decimal',
        name: 'qty',
        comment: '数量',
        transformer: decimalTransformer
    })
    qty: number;

    @Column({
        type: 'varchar',
        name: 'price',
        comment: '单价/单位'
    })
    price: string;

    @Column({
        type: 'decimal',
        name: 'amount',
        comment: '金额',
        transformer: decimalTransformer
    })
    amount: number;

    @ManyToOne(() => Invoice, (invoice) => invoice.details)
    @JoinColumn({
        name: 'invoice_id'
    })
    invoice: Invoice;
}


@Entity({
    name: 'v_invoice'
})
export class VInvoice extends Invoice {
    @Column({
        type: 'decimal',
        name: 'unaudit_pay_amount',
        comment: '未核销实收付发票金额',
        transformer: decimalTransformer
    })
    unaudit_pay_amount: number;
    @Column({
        type: 'decimal',
        name: 'unaudit_feedet_amount',
        comment: '未核销应收付发票金额',
        transformer: decimalTransformer
    })
    unaudit_feedet_amount: number;
}

export class InvoiceAudit extends YhBaseEntity {


    @Column({
        type: 'int',
        name: 'invoice_id',
        comment: '发票ID'
    })
    invoice_id: number;


    @Column({
        type: 'decimal',
        name: 'invoice_amount',
        comment: '核销发票金额',
        transformer: decimalTransformer
    })
    invoice_amount: number;

    @Column({
        type: 'varchar',
        name: 'audit_no',
        comment: '核销号'
    })
    audit_no: string;

    @Column({
        type: 'datetime',
        name: 'audit_tim',
        comment: '核销时间'
    })
    audit_tim: Date

    @Column({
        type: 'enum',
        enum: BooleanType,
        name: 'force_flag',
        comment: '强制核销'
    })
    force_flag: BooleanType;
}

@Entity({
    name: 'invoice_audit_pay'
})
export class InvoiceAuditPay extends InvoiceAudit {
    @Column({
        type: 'int',
        name: 'pay_id',
        comment: 'PAY_ID'
    })
    pay_id: number;

    
    @Column({
        type: 'decimal',
        name: 'pay_amount',
        comment: '核销实收付金额',
        transformer: decimalTransformer
    })
    pay_amount: number;
}

@Entity({
    name: 'invoice_audit_feedet'
})
export class InvoiceAuditFeedet extends InvoiceAudit {
    @Column({
        type: 'int',
        name: 'feedet_id',
        comment: 'feedet_ID'
    })
    feedet_id: number;

    
    @Column({
        type: 'decimal',
        name: 'feedet_amount',
        comment: '核销应收付金额',
        transformer: decimalTransformer
    })
    feedet_amount: number;
}

@Entity({
    name: 'v_audit_invoice_pay_group'
})
export class VAuditInvoicePayGroup {
    @PrimaryColumn({
        type: 'varchar',
        name: 'audit_no',
        comment: '核销号'
    })
    audit_no: string;

    @Column({
        type: 'datetime',
        name: 'audit_tim',
        comment: '核销时间'
    })
    audit_tim: Date;

}

@Entity({
    name: 'v_audit_invoice_pay_detail'
})
export class VAuditInvoicePayDetail extends YhBaseEntity{
    @Column({
        type: 'decimal',
        name: 'invoice_amount',
        comment: '发票核销金额',
        transformer: decimalTransformer
    })
    invoice_amount: number;
    @Column({
        type: 'decimal',
        name: 'pay_amount',
        comment: '核销实收付金额',
        transformer: decimalTransformer
    })
    pay_amount: number;
    @Column({
        type: 'enum',
        enum: BooleanType,
        name: 'force_flag',
        comment: '强制核销'
    })
    force_flag: BooleanType;

    @Column({
        type: 'datetime',
        name: 'audit_tim',
        comment: '核销时间'
    })
    audit_tim: Date;

    @Column({
        type: 'varchar',
        name: 'from_corp_nam',
        comment: '发票销售方名称'
    })
    from_corp_nam: string;

    @Column({
        type: 'varchar',
        name: 'to_corp_nam',
        comment: '发票购买方名称'
    })
    to_corp_nam: string;

    @Column({
        type: 'varchar',
        name: 'invoice_no',
        comment: '发票号'
    })
    invoice_no: string;

    @Column({
        type: 'varchar',
        name: 'invoice_currency_cod',
        comment: '发票货币'
    })
    invoice_currency_cod: string;

    @Column({
        type: 'int',
        name: 'fee_unit_cod',
        comment: '实收付客户'
    })
    fee_unit_cod: number;

    @Column({
        type: 'enum',
        enum: FeeInOutType,
        name: 'fee_in_out',
        comment: '收付类型'
    })
    fee_in_out: string;

    @Column({
        type: 'varchar',
        name: 'fee_typ_cod',
        comment: '费用类型'
    })
    fee_typ_cod: string;
    
    @Column({
        type: 'varchar',
        name: 'fee_cod',
        comment: '费目'
    })
    fee_cod: string;

    @Column({
        type: 'int',
        name: 'fee_owner',
        comment: '成本中心'
    })
    fee_owner: number;

    @Column({
        type: 'varchar',
        name: 'pay_currency_cod',
        comment: '货币'
    })
    pay_currency_cod: string;

    @Column({
        type: 'datetime',
        name: 'fee_tim',
        comment: '计费时间',
    })
    fee_tim: Date;
}

@Entity({
    name: 'v_audit_invoice_feedet_group'
})
export class VAuditInvoiceFeedetGroup {
    @PrimaryColumn({
        type: 'varchar',
        name: 'audit_no',
        comment: '核销号'
    })
    audit_no: string;

    @Column({
        type: 'datetime',
        name: 'audit_tim',
        comment: '核销时间'
    })
    audit_tim: Date;

}


@Entity({
    name: 'v_audit_invoice_feedet_detail'
})
export class VAuditInvoiceFeedetDetail extends YhBaseEntity{
    @Column({
        type: 'decimal',
        name: 'invoice_amount',
        comment: '发票核销金额',
        transformer: decimalTransformer
    })
    invoice_amount: number;
    @Column({
        type: 'decimal',
        name: 'feedet_amount',
        comment: '核销实收付金额',
        transformer: decimalTransformer
    })
    feedet_amount: number;
    @Column({
        type: 'enum',
        enum: BooleanType,
        name: 'force_flag',
        comment: '强制核销'
    })
    force_flag: BooleanType;

    @Column({
        type: 'datetime',
        name: 'audit_tim',
        comment: '核销时间'
    })
    audit_tim: Date;

    @Column({
        type: 'varchar',
        name: 'from_corp_nam',
        comment: '发票销售方名称'
    })
    from_corp_nam: string;
    @Column({
        type: 'varchar',
        name: 'to_corp_nam',
        comment: '发票购买方名称'
    })
    to_corp_nam: string;

    @Column({
        type: 'varchar',
        name: 'invoice_no',
        comment: '发票号'
    })
    invoice_no: string;

    @Column({
        type: 'varchar',
        name: 'invoice_currency_cod',
        comment: '发票货币'
    })
    invoice_currency_cod: string;

    @Column({
        type: 'int',
        name: 'fee_unit_cod',
        comment: '应收付客户'
    })
    fee_unit_cod: number;

    @Column({
        type: 'enum',
        enum: FeeInOutType,
        name: 'fee_in_out',
        comment: '收付类型'
    })
    fee_in_out: string;

    @Column({
        type: 'int',
        name: 'fee_owner',
        comment: '成本中心'
    })
    fee_owner: number;

    @Column({
        type: 'varchar',
        name: 'fee_typ_cod',
        comment: '应收付费用类型'
    })
    fee_typ_cod: string;
    @Column({
        type: 'varchar',
        name: 'fee_cod',
        comment: '应收付费目'
    })
    fee_cod: string;
    
    @Column({
        type: 'varchar',
        name: 'feedet_currency_cod',
        comment: '货币'
    })
    feedet_currency_cod: string;

    @Column({
        type: 'datetime',
        name: 'fee_tim',
        comment: '计费时间',
    })
    fee_tim: Date;

}

@Entity({
    name: 'c_fee_report'
})
export class FeeReportManager extends YhBaseEntity {
    @Column({
        type: 'varchar',
        name: 'r_name',
        comment: '报表名称'
    })
    r_name: string;

    @Column({
        type: 'enum',
        enum: FeeInOutType,
        name: 'fee_in_out',
        comment: '收付款'
    })
    fee_in_out: string;

    @OneToMany(() => FeeReportCfg, (cfg) => cfg.report)
    cfgs: FeeReportCfg[];

}

@Entity({
    name: 'c_fee_report_cfg'
})
export class FeeReportCfg extends YhBaseEntity {
    @Column({
        type: 'int',
        name: 'report_id',
        comment: '报表ID'
    })
    report_id: number;

    @Column({
        type: 'varchar',
        name: 'fee_cod',
        comment: '费目'
    })
    fee_cod: string;

    @ManyToOne(() => FeeReportManager, (report) => report.cfgs)
    @JoinColumn({
        name: 'report_id'
    })
    report: FeeReportManager;
}

@Entity({
    name: 'v_lease_fee_report'
})
export class LeaseFeeReport {
    @PrimaryColumn({
        type: 'int',
        name: 'lease_cntr_id',
        comment: '租箱ID'
    })
    lease_cntr_id: number;

    @PrimaryColumn({
        type: 'int',
        name: 'fee_unit_cod',
        comment: '客户'
    })
    fee_unit_cod: number;

    @PrimaryColumn({
        type: 'enum',
        enum: FeeInOutType,
        name: 'fee_in_out',
        comment: '收付类型'
    })
    fee_in_out: string;

    @PrimaryColumn({
        type: 'varchar',
        name: 'fee_cod',
        comment: '费目'
    })
    fee_cod: string;

    @PrimaryColumn({
        type: 'varchar',
        name: 'currency_cod',
        comment: '货币'
    })
    currency_cod: string;

    @PrimaryColumn({
        type: 'datetime',
        name: 'fee_tim',
        comment: '费用时间'
    })
    fee_tim: Date;

    @Column({
        type: 'int',
        name: 'out_cfs',
        comment: '提箱堆场'
    })
    out_cfs: number;

    @Column({
        type: 'datetime',
        name: 'out_date',
        comment: '提箱日期'
    })
    out_date: Date;

    @Column({
        type: 'datetime',
        name: 'back_date',
        comment: '还箱日期'
    })
    back_date: Date;

    @Column({
        type: 'int',
        name: 'back_cfs',
        comment: '还箱堆场'
    })
    back_cfs: number;

    @Column({
        type: 'int',
        name: 'lease_sn',
        comment: '提箱计划号'
    })
    lease_sn: number;

    @Column({
        type: 'int',
        name: 'rent_sn',
        comment: '还箱计划号'
    })
    rent_sn: number;

    @Column({
        type: 'int',
        name: 'cntr_no',
        comment: '箱ID'
    })
    cntr_no: number;

    @Column({
        type: 'varchar',
        name: 'cntr',
        comment: '箱号'
    })
    cntr: string;

    @Column({
        type: 'varchar',
        name: 'cntr_siz_cod',
        comment: '尺寸'
    })
    cntr_siz_cod: string;

    @Column({
        type: 'varchar',
        name: 'cntr_typ_cod',
        comment: '箱型'
    })
    cntr_typ_cod: string;

    @Column({
        type: 'varchar',
        name: 'bill_no',
        comment: '放箱号'
    })
    bill_no: string;

    @Column({
        type: 'varchar',
        name: 'lease_currency_cod',
        comment: '租箱费货币'
    })
    lease_currency_cod: string;

    @Column({
        type: 'decimal',
        name: 'day_rate',
        comment: '租箱费率',
        transformer: decimalTransformer
    })
    day_rate: number;

    @Column({
        type: 'int',
        name: 'fee_ton',
        comment: '数量',
    })
    fee_ton: number;

    @Column({
        type: 'decimal',
        name: 'amount',
        comment: '金额',
        transformer: decimalTransformer
    })
    amount: number;
}

@Entity({
    name: 'v_cntr_fee_group'
})
export class CfsFeeReport {
    @PrimaryColumn({
        type: 'int',
        name: 'id',
        comment: '箱编号'
    })
    id: number;

    @PrimaryColumn({
        type: 'int',
        name: 'fee_unit_cod',
        comment: '财务往来单位'
    })
    fee_unit_cod: number;

    @PrimaryColumn({
        type: 'enum',
        enum: FeeInOutType,
        name: 'fee_in_out',
        comment: '收付类型'
    })
    fee_in_out: string;

    @PrimaryColumn({
        type: 'varchar',
        name: 'fee_cod',
        comment: '费目'
    })
    fee_cod: string;

    @PrimaryColumn({
        type: 'varchar',
        name: 'currency_cod',
        comment: '货币'
    })
    currency_cod: string;

    @PrimaryColumn({
        type: 'datetime',
        name: 'fee_tim',
        comment: '计费日期'
    })
    fee_tim: Date;

    @Column({
        type: 'varchar',
        name: 'cntr',
        comment: '箱号'
    })
    cntr: string;

    @Column({
        type: 'varchar',
        name: 'cntr_siz_cod',
        comment: '尺寸'
    })
    cntr_siz_cod: string;

    @Column({
        type: 'varchar',
        name: 'cntr_typ_cod',
        comment: '箱型'
    })
    cntr_typ_cod: string;
    
    @Column({
        type: 'int',
        name: 'fee_ton',
        comment: '数量',
    })
    fee_ton: number;

    @Column({
        type: 'decimal',
        name: 'amount',
        comment: '金额',
        transformer: decimalTransformer
    })
    amount: number;


    in_cfs_tim?: Date;
    out_cfs_tim?: Date;
    stack_days?: number;
    cal_days?: number;
}